package io.renren.modules.school.service.impl;

import io.renren.modules.school.dao.SelectProfessionDao;
import io.renren.modules.school.entity.ProfessionEntity;
import io.renren.modules.school.entity.ProfessionLittleTypeEntity;
import io.renren.modules.school.entity.ProfessionTypeEntity;
import io.renren.modules.school.service.SelectProfessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service("SelectProfessionService")
public class SelectProfessionServiceImpl implements SelectProfessionService {

    @Autowired
    SelectProfessionDao selectProfessionDao;

    @Override
    public List selectNameByProfesisonType(Map params) {
        String ProfessionType = (String) params.get("ProfessionType");
        String level = (String) params.get("level");
        List schoolNameList = new ArrayList();
        List schoolByProfession = new ArrayList();
        List bigProfessionSchoolList = new ArrayList();
        List schoolData = new ArrayList();
        List schoolByName = new ArrayList();
        ProfessionEntity smallProfessionSchoolList = new ProfessionEntity();
        List<ProfessionTypeEntity> professionType = selectProfessionDao.selectProfessionLittleTypeByProfessionType(ProfessionType,level);
        for (ProfessionTypeEntity p : professionType) {
            Integer id = p.getItemId();
            List<ProfessionLittleTypeEntity> professionLittleType = selectProfessionDao.selectProfessionNameByProfessionLittleType(id);
            for (ProfessionLittleTypeEntity pp : professionLittleType) {
                String professionName = pp.getItemName();
                schoolNameList = selectProfessionDao.selectSchoolNameByProfessionName(professionName);
                schoolByProfession.add(schoolNameList);
            }
        }
        Integer count = 0;
        for (Integer i = 0; i < schoolByProfession.size(); i++) {
            bigProfessionSchoolList = (List) schoolByProfession.get(i);
            for (Integer f = 0; f < bigProfessionSchoolList.size(); f++) {
                smallProfessionSchoolList = (ProfessionEntity) bigProfessionSchoolList.get(f);
                schoolData.add(smallProfessionSchoolList);
            }
        }
        for(Integer s = 0;s<schoolData.size();s++){
            ProfessionEntity oneSchool = (ProfessionEntity) schoolData.get(s);
            String schoolCode = oneSchool.getSchoolCode();
            String schoolName = oneSchool.getSchoolName();
            Integer schoolId = oneSchool.getSchoolId();
            schoolByName = (List) selectProfessionDao.selectSchoolBySchoolName(schoolCode,schoolName,schoolId);
        }
        return schoolByName;
    }

    @Override
    public List selectSchoolByProfessionName(Map params) {
        String professionType = (String)params.get("idLearnType");
        String professionLevel = (String)params.get("idLevel");
        String professionWenLi = (String)params.get("idWenlike");
        String wl = professionWenLi+professionType+professionLevel;
        switch (wl){
            case "理科普通本科":params.put("predictor","putonglike");break;
            case "理科校企合作本科":params.put("predictor","xiaoqihezuolike");break;
            case "理科中外合作本科":params.put("predictor","zhongwaihezuolike");break;
            case "理科3+2连读本科":params.put("predictor","liandulike");break;
            case "理科春考本科":params.put("predictor","chunkaolike");break;
            case "理科艺术本科":params.put("predictor","yishulike");break;
            case "文科普通本科":params.put("predictor","putongwenke");break;
            case "文科校企合作本科":params.put("predictor","xiaoqihezuowenke");break;
            case "文科中外合作本科":params.put("predictor","zhongwaihezuowenke");break;
            case "文科3+2连读本科":params.put("predictor","lianduwenke");break;
            case "文科春考本科":params.put("predictor","chunkaowenke");break;
            case "文科艺术本科":params.put("predictor","yishuwenke");break;
            case "理科普通专科":params.put("predictor","zhuankeputonglike");break;
            case "理科校企合作专科":params.put("predictor","zhuankexiaoqilike");break;
            case "理科中外合作专科":params.put("predictor","zhuankezhongwaihezuolike");break;
            case "理科3+2连读专科":params.put("predictor","zhuankeliandulike");break;
            case "理科春考专科":params.put("predictor","zhuankechunkaolike");break;
            case "理科艺术专科":params.put("predictor","zhuankeyishulike");break;
            case "文科普通专科":params.put("predictor","zhuankeputongwenke");break;
            case "文科校企合作专科":params.put("predictor","zhuankexiaoqiwenke");break;
            case "文科中外合作专科":params.put("predictor","zhuankezhongwaihezuowenke");break;
            case "文科3+2连读专科":params.put("predictor","zhuankelianduwenke");break;
            case "文科春考专科":params.put("predictor","zhuankechunkaowenke");break;
            case "文科艺术专科":params.put("predictor","zhuankeyishuwenke");break;

        }
        if(params.get("idWenlike").equals("理科")){
            professionWenLi ="文科";
            params.put("professionWenLi",professionWenLi);
        }else{
            professionWenLi ="理科";
            params.put("professionWenLi",professionWenLi);
        }
        List universitys = selectProfessionDao.selectSchoolByProfessionName(params);
        return universitys;
    }
}
